<header>
    <h1><?php echo $user['User']['username'];?></h1>
    <?php 
    if ($this->Session->read('Auth.User.isAdmin')) {
        echo $this->Html->link('Add product', array('controller' => 'products', 'action' => 'add'));
    } ?>
</header>
<div class="content">
<?php 
    if ($this->Session->read('Auth.User.isAdmin')) : ?>
    <ul>
        <?php foreach ($products as $product) { ?>
        <li>
        <?php
            echo $product['Product']['name'];
            echo ' | ' . $this->Html->link('Edit', array('controller' => 'products', 'action' => 'edit', $product['Product']['id']));
        ?>
        </li>
        <?php } ?>
    </ul>
<?php
    else :
        if($this->Session->read('Auth.User.id') == $this->params['pass'][0] && ($user['Profile']['name'] == null))
        //|| $user['Profile']['pic'] == '/img/upload/default.png'
            echo "<div class='urgent'><h4>Please update your profile now!</h4></div>";
    ?>
        <ul class="profile clearfix">
            <li class="avatar">
        <?php
            echo $this->Html->image($user['Profile']['pic'], array('alt' => 'Profile picture')); ?>
            </li>
            <li class="info">
                <ul>
        <?php
            echo '<li> Name: ' . $user['Profile']['name'] . '</li>';
            echo '<li> Email: ' . $user['Profile']['email'] . '</li>';
            echo '<li> Contact: ' . $user['Profile']['contact'] . '</li>';
            echo '<li> Credit card no: ' . $user['Profile']['creditcard'] . '</li>';
            echo '<li> Available tokens: ' . $user['User']['token'] . '</li>';
        ?>
                </ul>
            </li>
        </ul>
        <div class="purchase">
            <a id="purchase">Buy more tokens</a>
            <?php
                echo $this->Form->create('User', array('action' => 'updateToken'));
                echo $this->Form->hidden('current', array('default' => $user['User']['token'] + $this->data['User']['token']));
                echo $this->Form->input('token', array('label' => 'The number of tokens you wanna buy'));
                echo $this->Form->end('buy');
            ?>
        </div>
    <?php endif; ?>
</div>
